# Definition for singly-linked list.
# class ListNode:
#     def __init__(self, val=0, next=None):
#         self.val = val
#         self.next = next
class Solution:
    def mergeTwoLists(self, list1: Optional[ListNode], list2: Optional[ListNode]) -> Optional[ListNode]:
        a = ListNode()
        now_node = a
        while (list1 != None) and (list2 != None):
            if list1.val <= list2.val:
                now_node.next = ListNode(list1.val)
                now_node = now_node.next
                list1 = list1.next
            else:
                now_node.next = ListNode(list2.val)
                now_node = now_node.next
                list2 = list2.next
        now_node.next = list1 or list2 
        return a.next